package com.fuqi.android.zhongcai.base.view.fragment;


import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.flyco.tablayout.SlidingTabLayout;
import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.application.UniApplication;
import com.fuqi.android.zhongcai.base.Constants;
import com.fuqi.android.zhongcai.base.view.adapter.MyPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * Created by Lenovo on 2016/8/29.
 */
public class OrderParentFragment extends BaseFragment {

    @Bind(R.id.order_parent_tablayout)
    SlidingTabLayout slidingTabLayout;
    @Bind(R.id.order_parent_viewpager)
    ViewPager viewPager;
    private List<String> mTitles = new ArrayList<>();
    private List<Fragment> mFragments = new ArrayList<Fragment>();
    public MyPagerAdapter mAdapter;

    private static OrderParentFragment fragment;

    public static OrderParentFragment getInstance(){
        if(fragment == null) fragment = new OrderParentFragment();
        return fragment;
    }

    @Override
    public void initView() {

        if (UniApplication.getInstance().getCurrentRole().equals(Constants.ROLE_GRKH)){
            // 用户
            mTitles.add("待审核");
            mTitles.add("待安装");
            mTitles.add("已完成");
            mFragments.add(OrderChildFragment.getInstance(Constants.DAI_SEHN_HE));
            mFragments.add(OrderChildFragment.getInstance(Constants.DAI_AN_ZHUANGQ));
            mFragments.add(OrderChildFragment.getInstance(Constants.YI_WAN_CHENG));

        } else if (UniApplication.getInstance().getCurrentRole().equals(Constants.ROLE_SGGR)){
            // 施工工人
            mTitles.add("待安装");
            mTitles.add("已完成");
            mFragments.add(OrderChildFragment.getInstance(Constants.DAI_AN_ZHUANGQ));
            mFragments.add(OrderChildFragment.getInstance(Constants.YI_WAN_CHENG));

        }else if (UniApplication.getInstance().getCurrentRole().equals(Constants.ROLE_JCY)){
            // 监察员
            mTitles.add("待抽查");
            mTitles.add("已抽查");
            mFragments.add(DaiChouChaFragment.getInstance(Constants.DAI_CHOU_CHA));
            mFragments.add(YiChouChaFragment.getInstance(Constants.YI_CHOU_CHA));

        }else if (UniApplication.getInstance().getCurrentRole().equals(Constants.ROLE_NQ)){
            // 内勤
                mTitles.add("待审核");
                mTitles.add("待安装");
                mTitles.add("已完成");
                mFragments.add(OrderChildFragment.getInstance(Constants.DAI_SEHN_HE));
                mFragments.add(OrderChildFragment.getInstance(Constants.DAI_AN_ZHUANGQ));
                mFragments.add(OrderChildFragment.getInstance(Constants.YI_WAN_CHENG));


        }else if (UniApplication.getInstance().getCurrentRole().equals(Constants.ROLE_SGDZ)){
            // 施工队长
                mFragments.add(OrderChildFragment.getInstance(Constants.DAI_CHU_LI));
                mFragments.add(OrderChildFragment.getInstance(Constants.DAI_AN_ZHUANGQ));
                mFragments.add(OrderChildFragment.getInstance(Constants.YI_WAN_CHENG));

                mTitles.add("待处理");
                mTitles.add("待安装");
                mTitles.add("已完成");
        }

        mAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager(),mTitles,mFragments);
        viewPager.setAdapter(mAdapter);
        slidingTabLayout.setViewPager(viewPager, mTitles, getActivity(), mFragments);

    }

    @Override
    public void initListener() {


    }

    @Override
    public void initData() {



    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_order_parent;
    }

}
